package icegps.com.pingdj.map.utils;

import icegps.com.pingdj.App;
import icegps.com.pingdj.map.bean.MapStatus;
import icegps.com.pingdj.map.bean.XYCAD;
import icegps.com.pingdj.map.listener.OnInfoAndConfigCallback;

/**
 * Created by 111 on 2018/3/16.
 */

public class DataManager {

    private final MeasureInfoManager measureInfoManager;
    private final TileUtils tileUtils;

    public DataManager(long loadToken, long saveToken, TileUtils tileUtils) {
        this.tileUtils = tileUtils;
        measureInfoManager = new MeasureInfoManager(loadToken,saveToken ,tileUtils);
    }

    public void startSaveMeasureInfoData(XYCAD xycad) {
        measureInfoManager.startSaveSQData(xycad);
    }

    public void setOnHeigthInfoCallback(OnInfoAndConfigCallback onHeigthInfoCallback) {
        measureInfoManager.setOnHeigthInfoCallback(onHeigthInfoCallback);
    }

    public void saveSQData() {
        measureInfoManager.saveSQData();
    }

    public void loadTile(MapStatus mapStatus) {
        tileUtils.loadTile(mapStatus);
    }

    public void setTileData(XYCAD xycad, MapStatus mapStatus) {
        tileUtils.setTileData(xycad, mapStatus);
    }

    public void saveAllTile() {
        tileUtils.saveAllTile();
    }

    public static void deleteDataByToken(long token) {
        TileUtils.deleteTile(token);
        App.getInstance().getDaoSession().getMapMeasureInfoDao().deleteByKey(token);
    }




}
